import re

site_prefix = '|'.join([

])
site_suffix = '|'.join(map(re.escape, [
    '.html'
]))
static_prefix = '|'.join([
    'service/',
    'uploads/',
    'upload/',
    'assets/',
    'public/',
    'static/',
    'media/',
    '\.\./',
    '\./'

])
static_suffix = '|'.join(map(re.escape, [
    # js / css
    '.js',
    '.css',

    # 图片
    '.jpeg',
    '.jpg',
    '.png',
    '.bmp',
    '.tif',
    '.gif',
    '.pcx',
    '.tga',
    '.exif',
    '.fpx',
    '.svg',
    '.psd',
    '.cdr',
    '.pcd',
    '.dxf',
    '.ufo',
    '.eps',
    '.ai',
    '.raw',
    '.wmf',
    '.webp',
    '.avif',

    # 视频
    '.avi',
    '.mp4',
    '.wmv',
    '.asf',
    '.asx',
    '.rmvb',
    '.rm',
    '.flv',
    '.dat',
    '.mkv',
    '.m4v',
    '.mov',

    # 音频
    '.wav',
    '.mp3',
    '.ape',
    '.flac',
    '.aac',
    '.opus',
    '.wv',

    # 字体
    '.woff2',
    '.woff',
    '.ttf',
    '.otf',
    '.fon',
    '.pfm',

    # 模板

    # 文件
    '.docx',
    '.doc',
    '.xlsx',
    '.xls',
    '.rar',
    '.zip',

    # 其他
    '.ico',
]))

static_suffix_reg = re.compile(f'({static_suffix})$')

static_url_reg = re.compile(
    fr'''(/?(?:{static_prefix})[\w%@/\.-_\-]+(?:{static_suffix}))''',
    re.I
)

url_reg = re.compile(
    '''((?:https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|])'''
    '''|'''
    '''((?://)[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|])'''
    '''|'''
    r'''(/?[-A-Za-z0-9+&@#/%?=~_|!:,.; ]+\.html)'''
    '''|'''
    fr'''(/?(?:{static_prefix})[\w@/._%=-]+(?:{static_suffix}))''',
    re.M | re.I
)

if __name__ == '__main__':
    print(static_url_reg.findall(
        '"src="/service/media/csc/image_list/319253a7144d49948bb47a2bca33c7de_w=320.png"\n"  " /static/base/css/bootstrap.min.css" " /static/base/js/jquery-1.12.4.min.js"'))
    print(url_reg.findall('/service/media/csc/image_list/319253a7144d49948bb47a2bca33c7de_w=320.png/media/chimoph/image_store/%E6%B2%AA%E6%BA%90%E5%8E%86%E5%8F%B2-2.jpg'))
    print(url_reg.findall('/service/media/chimoph/image_list/2021-05_广州展会2_w=500.JPG'))
    print(url_reg.findall('service/media/chimoph/image_list/2021-05_%E5%B9%BF%E5%B7%9E%E5%B1%95%E4%BC%9A2_w=500.'))
